package org.springsource.controllers;

import java.security.Principal;
import java.text.DateFormat;
import java.util.Date;
import java.util.List;
import java.util.Locale;

import javax.inject.Inject;
import javax.inject.Provider;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.crypto.password.StandardPasswordEncoder;
import org.springframework.social.connect.ConnectionRepository;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springsocial.domain.Player;
import org.springsocial.domain.Team;
import org.springsocial.services.AccountService;
import org.springsocial.services.CountryService;
import org.springsocial.services.PersonService;
import org.springsocial.services.PlayerService;
import org.springsocial.services.TeamService;

/**
 * Handles requests for the application home page.
 */
@Controller
public class HomeController {
	
	private static final Logger logger = LoggerFactory.getLogger(HomeController.class);
	
	
	
	@Autowired
	private TeamService teamService;
	
	
	/**
	 * Simply selects the home view to render by returning its name.
	 */
	
	@RequestMapping(value = "/", method = RequestMethod.GET)
	public String home(Principal currentUser, Model model) {
		logger.info("Welcome home! the client locale is ");
		
		List<Team> engTeams = teamService.getPremierLeagueTeams();
		List<Team> spanishTeams = teamService.getPrimeraDivisionTeams();
		
		model.addAttribute("engTeams", engTeams);
		model.addAttribute("spaTeams", spanishTeams);
		return "home";
	}
	
}
